<?php

namespace app\common\model;

use think\Model;
use common\util\Instance;
use think\Db;

class BaseModel extends Model
{
    use Instance;
    //PSR-4,PSR-0
    protected function prefixImgUrl ($value,$data){
        $finalUrl = $value;
        if($data['from'] == 1){
            $finalUrl = config('setting.img_prefix').$value;
        }
        return $finalUrl;
    }
    
    public function getItemsByIds($ids,$fields='*'){
        if(empty($ids)){
            return [];
        }
        return Db::name($this->table)->whereIn('id',$ids)->column($fields,'id');
    }
    
    public function insert($data) {
        return Db::name($this->table)->insertGetId($data);
    }
}
